#!/bin/sh
#
# Copyright (C) 2000-2023 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#

#
# Cleanup left over files, then load $SLOT1 into drive and    
#   write an EOF on it.
#

. scripts/functions

scripts/cleanup

# init slot for vtape driver
init_slot @tape_drive@ $SLOT1

if test x@autochanger@ != x/dev/null; then
   slot=`$scripts/@changer_script@ @autochanger@ loaded 0 @tape_drive@ $DRIVE1`
   case $slot in
   0)
      $scripts/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
      ;;
   $SLOT1)
      ;;
   *)
      $scripts/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1
      $scripts/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
      ;;
  esac
fi

init_drive @tape_drive@
